# CMakeList.txt: AIServer 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required(VERSION 3.8)
project(PathLib C CXX)

#这个就是定义各个版本对应的后缀，例如d，debug版本后缀，当然你想定义为其他，	#自己修改这块就可以了。
SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING "add a postfix, usually Debug")
SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually Release")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "rd" CACHE STRING "add a postfix, usually RelWithDebInfo")
SET(CMAKE_MINSIZEREL_POSTFIX "s" CACHE STRING "add a postfix, usually MinSizeRel")


include_directories( ${CMAKE_CURRENT_LIST_DIR} 
	$ENV{BOOST_PATH} # 需要配置boost库的环境变量
	${CMAKE_CURRENT_LIST_DIR}/Detour
)

LINK_DIRECTORIES($ENV{BOOST_PATH}/lib64-msvc-14.2)

#判断自己的编译状态
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
	MESSAGE(STATUS "current compilation type: Debug ")
	set(BIN_PATH ${PROJECT_SOURCE_DIR}/build/bin)
	set(LIB_PATH ${PROJECT_SOURCE_DIR}/build/lib)
ELSEIF(CMAKE_BUILD_TYPE MATCHES "Release")
	MESSAGE(STATUS "current compilation type: Release ")
	set(BIN_PATH ${PROJECT_SOURCE_DIR}/build/bin)
	set(LIB_PATH ${PROJECT_SOURCE_DIR}/build/lib)
ELSEIF(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
	MESSAGE(STATUS "current compilation type: RelWithDebInfo")
	set(BIN_PATH ${PROJECT_SOURCE_DIR}/build/bin)
	set(LIB_PATH ${PROJECT_SOURCE_DIR}/build/lib)
ELSEIF(CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
	MESSAGE(STATUS "current compilation type: MinSizeRel")
	set(BIN_PATH ${PROJECT_SOURCE_DIR}/build/bin)
	set(LIB_PATH ${PROJECT_SOURCE_DIR}/build/lib)
ENDIF()
#SET(CMAKE_BUILD_TYPE "Release")

add_definitions( -DMATHFU_COMPILE_WITHOUT_SIMD_SUPPORT )

#----------编译选项设置----------#
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
	add_definitions(-DWIN32 -DOUTPUT_DEBUG)

	SET(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3")
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3")
ENDIF()

#设置库文件存放路径
set(LIBRARY_OUTPUT_PATH ${LIB_PATH})
#设置执行文件存放路径
set(EXECUTABLE_OUTPUT_PATH ${BIN_PATH})
#添加include目录
#添加库目录 = -L
# 并将名称保存到 DIR_SRCS 变量
file(GLOB_RECURSE DIR_SRCS Detour/*.cpp Detour/*.h Detour/*.hpp 
	Finder/*.cpp Finder/*.h Finder/*.hpp 
	RecastDemo/*.cpp RecastDemo/*.h RecastDemo/*.hpp 
	DetourTileCache/Include/*.h DetourTileCache/Source/*.cpp 
	Contrib/fastlz/*.cpp Contrib/fastlz/*.h Contrib/fastlz/*.hpp Contrib/fastlz/*.c 
	Recast/*.cpp Recast/*.h 
	BridgeCpp.cpp BridgeCpp.h)

# 将源代码添加到此项目的可执行文件。
#add_executable (${PROJECT_NAME} ${DIR_SRCS})
#想得到动态库，参数就是SHARED
add_library( PathLib ${DIR_SRCS} )
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
	target_link_libraries(PathLib -lm)
ENDIF()

# TODO: 如有需要，请添加测试并安装目标。

# windows里面自己测试
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /std:c++17")

	file(GLOB_RECURSE TEST_SRCS ./test/src/*.cpp ./test/src/*.c ./test/src/*.h 
		./test/src/*.hpp )

	add_executable(test ${TEST_SRCS})
    target_link_libraries(test ${PROJECT_NAME})

ENDIF (CMAKE_SYSTEM_NAME MATCHES "Windows")

include_directories(${PROJECT_SOURCE_DIR}/)


add_executable(testbenchmark ./testbenchmark/src/testbenchmark.cpp)
target_link_libraries(testbenchmark PathLib )
